package com.quartz.job;

import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.PersistJobDataAfterExecution;

@Slf4j
//多次调用 Job 的时候，将参数保留在 JobDataMap
@PersistJobDataAfterExecution
public class JobStatus implements Job {
    @Override
    public void execute(JobExecutionContext context) {
        long count = (long) context.getJobDetail().getJobDataMap().get("count");
        log.info("当前执行，第" + count + "次");
        context.getJobDetail().getJobDataMap().put("count", ++count);

        log.info("Job中 开始时间:{}",context.getTrigger().getStartTime());
        log.info("Job中 结束时间:{}",context.getTrigger().getEndTime());
    }
}
